package impl.persons;

import framework.AbstractGame;
import framework.Business;
import framework.Person;
import framework.PersonAdapter;


/**
 * @author: Viktor Khimchenko
 * Date: 28.03.2008  0:28:31
 */
public class Jealous extends PersonAdapter {
    protected AbstractGame game;

    public Jealous(AbstractGame game) {
        this.game = game;
    }

    @Override
    public String getShortName() {
        return "JEAL";
    }

    @Override
    public int deal(Object id) {
        if (id instanceof Person) {
            Person person = (Person) id;
            int alien = game.getScore(person);
            if (alien > game.getScore(this)) {
                return Business.DEFECT;
            } else if (alien < game.getScore(this)) {
                return Business.COOPERATE;
            }
        }
        return Business.NEUTRAL;
    }
}
